<?php

use yii\helpers\Url;
use yii\helpers\Html;
use website\helpers\Render;
use common\models\Recruit;

$this->title = '招聘管理';
?>
<style>
    #info-table td {padding:10px;}
    #info-table td .flyer-status {margin-right:0 !important;}
</style>

<div class="contenter">
    <?= $this->render('/user/navigator', ['active' => 'recruit-list']) ?>
    
    <div id="user-contenter">
        <div class="box-shadow pb-20px" id="sub-contenter">
            <div class="data-title"><span class="h3"><?= $this->title ?></span></div>
            <div class="flyer-table simple">
                <table id="info-table" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr><td colspan="2"><i class="icon-search"></i> 数据加载中，请稍后.</td></tr>
                    </tbody>
                </table>
            </div>
            <div class="flyer-page mt right" id="info-page">
                <div class="html mr-10px"></div>
            </div>
        </div>
    </div>
</div>
<div style="display:none;">
    <?= Render::select('type', Recruit::$typeSelector, null, ['id' => 'recruit-type']) ?>
    <?= Render::select('status', Recruit::$statusSelector, null, ['id' => 'recruit-status']) ?>
</div>

<script src="<?= Render::static('art-template/template.js') ?>"></script>
<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tabler.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tableHandler.class.js') ?>"></script>
<script>
    $(document).ready(function() {
        // 初始化表格异步加载事件
        (new tabler).init({
            // 请求地址
            url: '<?= Url::to('@web/employer/recruit-list') ?>',
            // 数据渲染配置
            table: '#info-table', page: '#info-page', template: 'info-template', search: '#info-search', readyCall: true,
            // param => tabler
            afterPost: function(param) {
                // 名称显示
                tableHandler.renderCategory({ category: $(param.tabler).find('.type'), select: '#recruit-type' });
                tableHandler.renderCategory({ category: $(param.tabler).find('.status'), select: '#recruit-status' });
            }
        });
    });
</script>
<script id="info-template" type="text/html">
    {{if infos != undefined && infos.length}}
    {{each infos as info key}}
    <tr id="tr-{{info.id}}" data-id="{{info.id}}">
        <td class="first">
            <p>{{info.title}}</p>
            <p>
                <span>发布日期：{{info.created_at | dateShow: format = 'day'}}</span>
                <span class="ml-20px">状态：<span class="status">{{info.status}}</span></span>
            </p>
        </td>
        <td class="tar">
            <p class="type">{{info.type}}</p>
            <p>
                <a class="flyer-button normal border-round narrow thin" href="<?= Url::to('@web/employer/recruit-applicant?id=') ?>{{info.id}}"><i class="icon-th-list"></i> 投递管理</a>
                <a class="flyer-button normal border-round narrow thin" href="<?= Url::to('@web/employer/recruit?id=') ?>{{info.id}}"><i class="icon-edit"></i> 修改需求</a>
            </p>
        </td>
    </tr>
    {{/each}}
    {{else}}
    <tr>
        <td class="first" colspan="2"><i class="icon-ban-circle"></i> 搜索程序未为您搜索到任何信息！</td>
    </tr>
    {{/if}}
</script>